package JavaTest.extendsTest;

public class People {
    /**name 长度不超过12*/
    private String name;
    /**age 在0-120岁以内*/
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if (name.length() > 12){
            System.out.println("姓名过长");
            name = "error";
        }
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age < 0 || age > 120){
            this.age = 18;
        }
        this.age = age;
    }
}
